package com.itheima.mm.controller;
import com.itheima.mm.entity.Result;
import com.itheima.mm.pojo.Company;
import com.itheima.mm.service.ICompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * 包名:com.itheima.mm.controller
 * 作者:Leevi
 * 日期2020-01-16  11:05
 */
@RestController
@RequestMapping("company")
public class CompanyController {
    @Autowired
    private ICompanyService companyService;
    @RequestMapping("findAll")
    public Result findAll() throws IOException {
        try {
            List<Company> companyList =  companyService.findAll();
            //获取企业列表成功
            //将Result对象转换成json响应给客户端
            return new Result(true,"获取企业列表成功",companyList);
        } catch (Exception e) {
            e.printStackTrace();
            //获取企业列表失败
            return new Result(false,"获取企业列表失败");
        }
    }
}
